package com.example.service;

import com.example.entity.BooksContent;
import com.example.entity.BooksHistory;
import com.example.mapper.BooksHistoryMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
历史记录书籍业务处理
 */
@Service
public class BooksHistoryService {

    @Resource
    private BooksHistoryMapper booksHistoryMapper;

    public void add(BooksHistory booksHistory) {
        booksHistoryMapper.insert(booksHistory);
    }

    public void deleteById(Integer id) {
        booksHistoryMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(BooksHistory booksHistory) {
        booksHistoryMapper.updateById(booksHistory);
    }

    public BooksHistory selectById(Integer id) {
        return booksHistoryMapper.selectById(id);
    }

    public List<BooksHistory> selectAll(BooksHistory booksHistory) {
        return booksHistoryMapper.selectAll(booksHistory);
    }

    public PageInfo<BooksHistory> selectPage(BooksHistory booksHistory, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<BooksHistory> booksHistoryList = booksHistoryMapper.selectAll(booksHistory);
        return PageInfo.of(booksHistoryList);
    }
}
